﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DevExpress.Web.Mvc;
using Sovigaz.Report;

namespace Sovigaz.Controllers
{
    public class ReportController : Controller
    {
        public ActionResult ProductList(int? id)
        {
            if (id.HasValue)
                Session["ProductList"] = new Report.ReportProductList.Report(id.Value);
            else
                Session.Remove("ProductList");

            ViewBag.LotID = id ?? 0;
            ViewBag.DocumentViewer = "ProductListDocumentViewerPartial";
            ViewBag.ExportViewer = "ProductListExportViewerPartial";

            return View();
        }

        public PartialViewResult ProductListDocumentViewerPartial()
        {
            ViewBag.DocumentViewer = "ProductListDocumentViewerPartial";
            ViewBag.ExportViewer = "ProductListExportViewerPartial";

            return PartialView("DocumentViewerPartial", Session["ProductList"] as ReportBase);
        }

        public ActionResult ProductListExportViewerPartial()
        {
            return ReportViewerExtension.ExportTo(Session["ProductList"] as ReportBase);
        }
    }
}
